<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">

      <div>
        <!-- 搜索 -->
        <el-input v-model="query.blurry" clearable size="small" placeholder="模糊搜索" style="width: 170px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <rrOperation :crud="crud" />
      </div>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column align="center" prop="bisQyZt" label="签约状态">
          <template slot-scope="scope">
            {{ dict.label.qygl[scope.row.bisQyZt] }}
          </template>
        </el-table-column>
        <el-table-column align="center" prop="bisZhsqZt" label="申请状态" width="130">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.bisZhsqZt === '05'" effect="plain" type="">
              {{ dict.label.zhzt[scope.row.bisZhsqZt] }}
            </el-tag>
            <el-tag v-else-if="scope.row.bisZhsqZt === '00'" effect="plain" type="warning">
              {{ dict.label.zhzt[scope.row.bisZhsqZt] }}
            </el-tag>
            <el-tag v-else effect="plain" type="danger">
              {{ dict.label.zhzt[scope.row.bisZhsqZt] }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="bisZhsqSnryXm" label="姓名" />
        <el-table-column align="center" prop="bisZhsqSnryXb" label="性别" />
        <el-table-column align="center" prop="bisZhsqNl" label="年龄" />
        <el-table-column align="center" prop="bisZhsqSnrySfz" label="身份证" width="150" />
        <el-table-column align="center" prop="lrsj" label="申请时间" width="150" />
        <el-table-column align="center" prop="bisQyQysj" label="签约日期" width="90" />
        <el-table-column align="center" prop="bisZhsqHldzSsqx" label="所属区县">
          <template slot-scope="scope">
            {{ dict.label.ccs[scope.row.bisZhsqHldzSsqx] }}
          </template>
        </el-table-column>
        <el-table-column align="left" prop="bisSbgsQymc" label="商保公司" width="300" />
        <el-table-column align="left" prop="bisHljgQymc" label="护理机构" width="250" />
        <el-table-column align="center" prop="bisZhsqDykkrq" label="待遇开始日期" width="100" />
        <el-table-column align="center" prop="bisZhsqDyjsrq" label="待遇结束日期" width="100" />
        <el-table-column align="center" prop="bisZhsqXsdyq" label="享受待遇期" />
        <el-table-column align="center" prop="bisZhsqAdl" label="ADL评分" />
        <el-table-column align="center" prop="bisZhsqJhrxm" label="监护人姓名" />
        <el-table-column align="center" prop="bisZhsqJhrdh" label="监护人电话" width="130" />
        <el-table-column align="center" prop="bisZhsqGx" label="关系">
          <template slot-scope="scope">
            {{ dict.label.yjsgx[scope.row.bisZhsqGx] }}
          </template>
        </el-table-column>
        <el-table-column align="center" prop="bisZhsqSnryYbssqx" label="医保所属区县" width="130">
          <template slot-scope="scope">
            {{ dict.label.ccstcqh[scope.row.bisZhsqSnryYbssqx] }}
          </template>
        </el-table-column>
        <el-table-column align="left" prop="bisZhsqHldz" label="护理地址" width="250">
          <template slot-scope="scope">
            {{ scope.row.bisZhsqHldz }}({{ scope.row.bisZhsqHldzXxdz }})
          </template>
        </el-table-column>
        <el-table-column align="center" prop="bisZhsqGrbh" label="人员编号" />
        <el-table-column align="center" prop="bisZhsqYbkh" label="医保卡号" width="90" />
        <el-table-column align="center" prop="bisZhsqLxdh" label="联系电话" width="100" />
        <el-table-column
          fixed="right"
          label="操作"
          width="100"
        >
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="handleClick(scope.row)">重新分配签约员</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
      <dspQyry ref="dspQyry" @doQuery="doApproveQuery" />
    </div>
  </div>
</template>

<script>
import dspQyry from './dspQyry'
import CRUD, { presenter, header, form } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import pagination from '@crud/Pagination'

const defaultForm = { bisZhsqId: null, bisZhsqSnryId: null, bisZhsqSnryXm: null, bisZhsqSnryXb: null, bisZhsqSnrySfz: null, bisSnryYbssqx: null, bisZhsqDykkrq: null, bisZhsqDyjsrq: null, bisZhsqXsdyq: null, bisZhsqAdl: null, bisZhsqZt: null }
export default {
  name: 'Zhsq',
  components: { pagination, rrOperation, dspQyry },
  mixins: [presenter(), header(), form(defaultForm)],
  dicts: ['xb', 'yjsgx', 'ccs', 'zhzt', 'ccstcqh', 'qygl'],
  cruds() {
    return CRUD({ title: '居家照护申请', url: 'api/qy/queryYfpList', idField: 'bisZhsqId', sort: 'lrsj,desc' })
  },
  data() {
    return {
      approveDialog: false,
      selectedZhids: [],
      bisGsglId: '',
      permission: {
        add: ['admin', 'zhsq:add'],
        edit: ['admin', 'zhsq:edit'],
        del: ['admin', 'zhsq:del']
      },
      rules: {
        bisZhsqSnryXm: [
          { required: true, message: '姓名不能为空', trigger: 'blur' }
        ],
        bisZhsqSnryXb: [
          { required: true, message: '性别不能为空', trigger: 'blur' }
        ],
        bisZhsqSnrySfz: [
          { required: true, message: '身份证不能为空', trigger: 'blur' }
        ],
        bisSnryYbssqx: [
          { required: true, message: '医保所属区县不能为空', trigger: 'blur' }
        ],
        bisZhsqDykkrq: [
          { required: true, message: '待遇开始日期不能为空', trigger: 'blur' }
        ],
        bisZhsqDyjsrq: [
          { required: true, message: '待遇结束日期不能为空', trigger: 'blur' }
        ],
        bisZhsqXsdyq: [
          { required: true, message: '享受待遇期不能为空', trigger: 'blur' }
        ],
        bisZhsqAdl: [
          { required: true, message: 'ADL量表评分不能为空', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    },
    assign() {
      console.log(this.crud.data)
      /*
      this.selectedZhids = []
      this.crud.selections.forEach((item, index) => {
        this.selectedZhids.push(item.bisZhsqId)
      })
      if (this.selectedZhids.length === 0) {
        this.$notify({
          title: '请选择待分配的照护申请',
          type: 'warning',
          duration: 2500
        })
        return
      }
      this.$refs.dspPgry.PgryDialog = 1
      this.$refs.dspPgry.selectedZhids = this.selectedZhids
      */
    },
    doApproveQuery() {
      console.log('233333333333333333333333333')
      this.crud.toQuery()
    },
    handleClick(rowOjb) {
      this.selectedZhids = []
      this.selectedZhids.push(rowOjb.bisZhsqId)

      if (this.selectedZhids.length === 0) {
        this.$notify({
          title: '请选择待分配的照护申请',
          type: 'warning',
          duration: 2500
        })
        return
      }
      this.$refs.dspQyry.QyryDialog = 1
      this.$refs.dspQyry.selectedZhids = this.selectedZhids
    }
  }
}
</script>

<style scoped>

</style>
